package com.chmingx.admin.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 处理全局异常
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler({NullPointerException.class}) // 能处理的异常
    public String handleNullPointerException(Exception e) {
        System.out.println(e.getMessage());
        return "index"; // 需要返回一个ModelAndView， 可以直接指定页面，即index.html
    }
}
